#include <stdio.h>
#include <stdint.h>

#include "drivers/cc2420.h"


uint8_t test[] = {0x00, 0x06, 'a', 'b', 'c', 0x00, 0xCA, 0xCA,
 0x00, 0x07, 'd', 'e', 'f', 'g', 0x00, 0xCB, 0xCB,
 0x00, 0x0A, 'h', 'i', 'j', 'k', 'l', 'm', 'n', 0x00, 0xCC, 0xCC};
uint16_t index;

void cc2420_strobe(enum cc2420_strobe s)
{
	printf("strobe: %d\n", s);
}

uint8_t spi_send_receive(uint8_t m)
{
	printf(\
"\
%x -> ret: %x(%c)\n\
", m, test[index], test[index]);

	return test[index++];
}

int main(int argc, char * argv[])
{
	uint8_t buffer[128];
	index = 0;

	cc2420_read_rxfifo();
	if (cc2420_get_frame(&(buffer[0])))
		printf("read: %s\n", buffer);
	print_buffer();

	cc2420_read_rxfifo();
	/* Fails */
	//cc2420_read_rxfifo();
	print_buffer();
	if (cc2420_get_frame(&buffer))
		printf("read: %s\n", buffer);
	/* Reads last test */
	cc2420_read_rxfifo();
	print_buffer();
	if (cc2420_get_frame(&buffer))
		printf("read: %s\n", buffer);
	print_buffer();
}
